﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

using BLL;
using DAL;
using Models;
using System.Data;
using System.Text;
using System.Xml;
using Web.Old_App_Code;

public partial class backstage_order_bulk : System.Web.UI.Page
{


    protected OrderManager om = new OrderManager();

    // Methods
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            Array array = base.Request.QueryString["oId"].Split(new char[] { ',' });
            foreach (string str in array)
            {
                this.om.BulkModifyOrderById(Convert.ToInt32(str), this.selectOrderStatus.Value, this.selectDeliveryStatus.Value, this.selectPayStatus.Value);
            }
            base.ClientScript.RegisterStartupScript(base.GetType(), "message", "<script language=\"javascript\" defer>alert(\"更新成功！\");location.href=\"order_list.aspx\";</script>");
        }
        catch
        {
            base.ClientScript.RegisterStartupScript(base.GetType(), "message", "<script language=\"javascript\" defer>alert(\"更新失败！\");</script>");
        }
    }

    private void GetOrderNo()
    {
        try
        {
            Array array = base.Request.QueryString["oId"].Split(new char[] { ',' });
            int num = 0;
            foreach (string str in array)
            {
                DataTable orderById = this.om.GetOrderById(Convert.ToInt32(str));
                this.lblOrderNo.InnerHtml = this.lblOrderNo.InnerHtml + ((num == 0) ? ("[" + orderById.Rows[0]["orderNo"].ToString() + "]") : ("<br />[" + orderById.Rows[0]["orderNo"].ToString() + "]"));
                num++;
            }
        }
        catch
        {
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if ((HttpContext.Current.Session["admin_user"] == null) && (HttpContext.Current.Session["language_version"] == null))
        {
            base.ClientScript.RegisterStartupScript(base.GetType(), "sJs", "top.location=\"login.html\";", true);
        }
        if (!(base.IsPostBack || (base.Request.QueryString["oId"] == null)))
        {
            this.GetOrderNo();
        }
    }

}